home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
compdem.zip
/
ETZIP.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-02-16
|
8KB
|
209 lines
' ETZIP.EXE
' (C) Copyright 1992-1993 EllTech Development, Inc.
' All rights reserved
' Be sure to link with the /STACK:4096 switch!
' =======================================================================
REM $INCLUDE: 'compress.bi'
REM $INCLUDE: 'compres2.bi'
REM $INCLUDE: 'etdecasm.bi'
Version$ = "1.00"
Cmd$ = UCASE$(COMMAND$)
PRINT
PRINT "ETZIP v"; Version$
PRINT "Data Compression Utility"
PRINT "(C) Copyright 1992-1993 EllTech Development, Inc."
PRINT "All rights reserved."
PRINT
PRINT "This utility demostrates some of the capabilities of EllTech's"
PRINT CHR$(34); "Compression Plus"; CHR$(34); " data compression library for QuickBASIC"
PRINT "PDS, and VBDOS programmers. For more information, contact "
PRINT "EllTech Development, Inc. at (404) 928-8960 or on CIS at 76220,2575."
PRINT
IF LEN(Cmd$) = 0 THEN 'If no command line arguments were
GOTO ShowHelp ' passed in, remind the user the
END IF ' program syntax.
DIM Param$(1 TO 20, 0 TO 1)
Sep$ = " "
CALL EtParseCmdLine(Cmd$, Sep$, Param$(), Found%) 'Otherwise, parse out the command line
IF Found% < 1 THEN 'zip file name is required
GOTO ShowHelp 'remedial reading :-)
END IF
Pcnt% = 0
SpecCnt% = 0
REDIM Spec$(1 TO 10)
FOR I% = 1 TO Found%
SELECT CASE LEFT$(Param$(I%, 0), 1)
CASE "-", "/": 'this is a switch
Switch$ = Switch$ + Param$(I%, 0)
CASE ELSE
Pcnt% = Pcnt% + 1
SELECT CASE Pcnt%
CASE 1 'first non-switch is arc file name
ArcFile$ = Param$(I%, 0)
CASE IS >= 2 'other non-switch params are file specs
IF SpecCnt% < UBOUND(Spec$) THEN
SpecCnt% = SpecCnt% + 1
Spec$(SpecCnt%) = Param$(I%, 0)
END IF
CASE ELSE
END SELECT
END SELECT
NEXT
IF INSTR(ArcFile$, ".") = 0 THEN 'default extension
ArcFile$ = ArcFile$ + ".zip"
END IF
IsItThere% = EtFileExist%(ArcFile$) 'check existence of archive file
IF NOT IsItThere% THEN
Status% = EtFileOpen(ArcFile$, 0, Handle%) 'check archive name
EtFileClose Handle%
IF Status% THEN
PRINT "Illegal File Name: "; ArcFile$ 'sorry bad file name
GOTO ShowHelp 'remedial reading
ELSE
Temp% = EtFileDelete%(ArcFile$) 'delete the one we opened
END IF
END IF
IF SpecCnt% = 0 THEN
SpecCnt% = 1
Spec$(1) = "*.*" 'default spec
END IF
IF INSTR(Switch$, "V") + INSTR(Switch$, "D") = 0 THEN 'if we're not viewing or deleting from an existing zip
BadSpec% = 0 'benefit of the doubt
FOR I% = 1 TO SpecCnt%
IF NOT EtFileExist%(Spec$(I%)) THEN 'any files for this spec
BadSpec% = BadSpec% + 1 'its a BAD spec
Spec$(I%) = "" 'clear it
END IF
NEXT
IF SpecCnt% - BadSpec% < 1 THEN 'nothing to do
PRINT "No Files to Archive: "; Spec$
GOTO ShowHelp
END IF
END IF
IF INSTR(Switch$, "V") THEN
Status% = EtViewZip%(ArcFile$, Spec$())
ELSE
Status% = EtZipOpen%(ArcFile$, Mode%, Handle%)
IF Status% = 0 THEN
Status% = EtZip%(Handle%, Spec$(), Switch$)
END IF
END IF
IF Status% = 0 AND INSTR(Switch$, "Z") THEN
Status% = EtFileOpen(ArcFile$, 0, Handle%)
IF Status% = 0 THEN
OldComment$ = EtZipComment$(Handle%, Status%)
IF LEN(OldComment$) AND Status% = 0 THEN
PRINT
PRINT "Old Comment:"; OldComment$
END IF
PRINT
IF EtRedirected2% THEN
Bytes& = 1000
Buffer$ = SPACE$(Bytes&)
RedirHandle% = 0
DO
EtStringInfo Buffer$, Segment%, Offset%
Status% = EtFileRead%(RedirHandle%, Segment%, Offset%, Bytes&)
Comment$ = Comment$ + LEFT$(Buffer$, Bytes&)
LOOP UNTIL Status%
Status% = 0
I% = INSTR(Comment$, CHR$(26)) 'check for eof marker
IF I% > 0 THEN
Comment$ = LEFT$(Comment$, I% - 1)
END IF
DO 'remove lf from crlf
I% = INSTR(Comment$, CHR$(13) + CHR$(10))
IF I% > 0 THEN
Comment$ = LEFT$(Comment$, I%) + MID$(Comment$, I% + 2)
ELSE
EXIT DO
END IF
LOOP
ELSE
INPUT "Enter Zip Comment:", Comment$
END IF
IF LEN(Comment$) THEN
Status% = EtZipNewComment%(Handle%, Comment$)
END IF
END IF
END IF
IF Status% THEN
SELECT CASE Status%
CASE -1
ArcType% = EtArcType%(Handle%, Status%)
SELECT CASE ArcType%
CASE 2:
PRINT "Cannot Compress ARJ files ... Use -v to view"
CASE 3:
PRINT "Cannot Compress LZH files ... Use -v to view"
CASE ELSE
PRINT "Unrecognized File Format: "; ArcFile$
END SELECT
CASE -2
PRINT "Error in Archive: "; ArcFile$
CASE -3
PRINT "Unknown Compression Method"
CASE -4
PRINT "Encrypted File"
CASE -5
PRINT "CRC Error"
CASE -6
PRINT "Archive Not Found"
CASE -7
PRINT "No Files to Compress"
CASE -8
PRINT "Errors Encountered"
CASE IS > 0
PRINT "DOS Error : "; Status%
CASE ELSE
PRINT "Error Status: "; Status%
END SELECT
ELSE
PRINT
PRINT "Operation Successful!"
END IF
IF Handle% THEN
EtZipClose Handle%
END IF
GOTO AllDone
ShowHelp:
PRINT
PRINT "Syntax: EtZip [Switches] ArchiveFile FileSpec [FileSpec...]"
PRINT "ie: EtZip -p Stuff.Zip *.*"
PRINT
PRINT "Valid Switches: -p Store paths"
PRINT " -d Delete file from zip"
PRINT " -v View Zip Directory"
PRINT " -z Add/Edit Zip Comment"
PRINT " -es Shrink only"
PRINT " -ei Implode only"
PRINT " -ec Scrunch only"
PRINT " -eh Huffman only"
PRINT " -em Mash only"
PRINT " -et Store only"
AllDone:
END